<%--
    Document   : sanpham_danhsach
    Created on : Nov 23, 2011, 8:51:41 PM
    Author     : kydrenw
--%>

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
    function check_tim_sp()
    {
        if(document.frm_timsp.danhmuc.value==0)
        {
            alert("Bạn chưa chọn danh mục tìm kiếm")
            document.frm_timsp.danhmuc.focus()
            return false
        }
        if(document.frm_timsp.txttukhoa.value=="" || document.frm_timsp.txttukhoa.value=="Nhập từ khóa muốn tìm")
        {
            alert("Bạn chưa nhập từ khóa tìm kiếm")
            document.frm_timsp.txttukhoa.select()
            return false
        }
        return true
    }
</script>

<div class="box-head">Danh Sách Sản Phẩm</div>
<form action="sanpham.htm" method="post" name="frm_timsp" id="frm_timsp" onsubmit="return check_tim_sp()" class="formSearch">
    <div>
        <span>
            <select name="danhmuc" id="danhmuc">
                <option value="1">Tên sản phẩm</option>
                <option value="2">Loại sản phẩm</option>
                <option value="3">Thông tin sản phẩm</option>
            </select>
        </span>
        <span>
            <input name="txttukhoa" type="search" id="txttukhoa" onclick="this.value=''" placeholder="Tìm ..."/>
        </span>
        <span>
            <input type="hidden" name="action" value="timkiem"/>
            <input type="submit" name="Submit" value="" class="btn btnSearch" title="Tìm"/>
        </span>
        <span>
            <input type="button" value="" class="btn btnAdd" onclick="window.location='sanpham.htm?action=them'" title="Thêm sản phẩm"/>
        </span>
    </div>
</form>
<div class="note">
    ${message}
</div>


    <table width="100%">
        <tr>
            <td class="tbhead">Mã sản phẩm</td>
            <td class="tbhead">Tên sản phẩm</td>
            <td class="tbhead">Hình ảnh</td>
            <td class="tbhead">Giá</td>
            <td class="tbhead">Danh mục</td>
            <td class="tbhead">Loại sản phẩm</td>
            <td class="tbhead">Tình trạng</td>
            <td class="tbhead">Chỉnh sửa</td>
        </tr>
        <c:forEach var="item" items="${ds}">
            <tr>
                <td class="tbcontent tensp">${item.masp}</td>
                <td class="tbcontent tensp">${item.tensp}</td>
                <td class="tbcontent tensp"><img src="${item.hinhanh}" height="100px"/></td>
                <td class="tbcontent gia">${item.gia}</td>
                <td class="tbcontent danhmuc">${item.loaisp.danhmuc.ten}</td>
                <td class="tbcontent loaisp">${item.loaisp.ten}</td>
                <td class="tbcontent">
                    <c:choose>
                        <c:when test="${item.tinhtrang.ma==5}">
                            <font color="green">${item.tinhtrang.ten}</font>
                        </c:when>
                        <c:otherwise>
                            <font color="red">${item.tinhtrang.ten}</font>
                        </c:otherwise>
                    </c:choose>
                </td>

                <td class="tbcontent">
                    <input title="Sửa" type="button" class=" btn btnEdit" onclick="window.location='sanpham.htm?action=sua&ma=${item.masp}'"/>
                    <input title="Xóa" type="button" class=" btn btnDel" onclick="return confirm('Bạn có chắc chắn muốn xóa không ?'), window.location='sanpham.htm?action=xoa&ma=${item.masp}'"/>
                </td>
            </tr>
        </c:forEach>
    </table>


<div class="trang">Trang
    <c:forEach var="i" begin="1" end="${totalPages}">
        <c:choose>
            <c:when test="${page==i}">
                <span class="pageSel">${i}</span>
            </c:when>
            <c:otherwise>
                <a href='sanpham.htm?danhmuc=${danhmuc}&txttukhoa=${tukhoa}&page=${i}' class="pageUnSel">${i} </a>
            </c:otherwise>
        </c:choose>
    </c:forEach>
</div>